class Singleton2{
    private static people:Singleton2 = new Singleton2('饿汉式单例模式');
    private name:string;

    private constructor(name) {
        this.name = name;
    }

    public static getInstance():Singleton2{
        return Singleton2.people;
    }

    public say():void{
        console.log(this.name);
    }
}

/*测试代码*/
let s = Singleton2.getInstance();
s.say(); //饿汉式单例模式
